Repository navigation
Conversation
Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>
|
The affected modules are Core, Desktop. @hidb4ai, please coordinate follow-up. Core: @hidb4ai @frf12 @Fengzdadi @beatenevo; Desktop: @PsiACE @knqiufan. Please coordinate the review of the affected changes. |
Record an existing SQLite publication opened and refreshed by the candidate without changing its target identity, history, or retry semantics. Keep the required installed-release acceptance matrix unchanged. Assisted-by: OpenAI Codex
|
I followed up on the upgrade preflight in dd5e427. I created a Topic Memory publication with the base Server source (07f4190), closed it, then opened the same SQLite database with the candidate and refreshed using the original key. The target ID stayed the same, both exact provenance edges remained readable after restart, delayed and same-content retries were skipped, and search returned only the current content. The local upgrade policy check and 166 focused tests passed. I also repeated the old-database check against GitHub’s current merge preview. The commit records the compatibility rationale and digest without changing the required upgrade matrix. The installed-release upgrade cases, including native seekDB and OceanBase, still need to run in CI. CI update: the upgrade preflight passed. The Dify job stopped at the generated-contract check, so I regenerated the two tool declarations and the bundled contract in dc58864. Those are the only files changed. The generator check, 85 Dify plugin tests and 3 Dify HTTP/SQLite tests passed locally on the same tree as GitHub’s new merge preview. The hosted Dify run and installed-release upgrade results are still pending. |
Fengzdadi
left a comment
There was a problem hiding this comment.
Thanks for the detailed description and the regression tests. I reviewed dc58864 against current master (9e40f89); the branch merges cleanly. I ran the checks below on dd5e427; dc58864 changes only the three regenerated Dify files.
One blocking issue, in _publish_artifact_access (inline): a user with scope.contribute in both Scopes can replace the head of an existing shared Topic through a refresh, while the same user still gets 403 for a direct replace.
What I checked:
- Refresh works as described on the merge result. A newer, changed source revision appends a target revision under the same Artifact ID with
X-Publication-Outcome: replaced, retries of older and already published source revisions returnskipped, and each published target revision'spublished_fromnames its exact source revision. - A refreshed publication survives a portable archive round trip. After both Scopes are restored into an empty database, both target revisions keep
published_from, retries of source revisions 1 and 2 returnskipped, and a new source revision refreshes the restored copy and its search index. - The leading-space internal keys can't collide with client keys, because
ArtifactPublicationRequestrejects untrimmedidempotency_keyvalues. forgetandGET …/governancereturn 422 for Topic Memory, so a refresh can't target a forgotten copy.scripts/generate_api.py --check,scripts/generate_js_operations.py --checkandscripts/schema_release.py check --base-refagainst current master pass. The related publication, access, Topic Memory, archive, MCP, contract, Desktop and dashboard suites pass on the merge result and on master.- The new Desktop record matches this head's contract (
ddf2bd3e…) and covers every operation inoperations.json. - The Dify files in dc58864 match a local run of
integrations/dify/generate_contract.py, and its--checkpasses on the merge result.
CI: on dc58864 it had only started when I checked. On dd5e427 the unit and e2e jobs passed, dify-tools failed at the contract check that dc58864 fixes, and the remaining jobs were cancelled after the new push.
Design notes (non-blocking):
response_model_exclude_unset=Truealso changescreated_byon rollback revisions (inline).- Removing the Scope-row
UPDATEat the start of_publishleaves the publication, Topic Memory and access tests passing. The extended race test pauses the older request inembed(), before its write transaction starts, so it exercises the recheck but not this lock, which the comment says serializes publications across server processes. A test that holds one request inside its write transaction would protect it. - The new Desktop record's
serverCommitisworking-tree-sha256:1a98d826…. Nothing in the repository computes that digest, andrebuilt_profile()requires a 40-hex commit, so the wheeld7915689…can't be traced to source. #2246 added three records like this, so it follows precedent; qualifying from a pushed commit, or adding the build command and version string to the PR description, would make it checkable. - README: the new bullet ends its bold title with a period (
。in the Chinese and Japanese files), while its neighbors end theirs with a colon (:).
| (AccessAction.SCOPE_CONTRIBUTE, ResourceRef.scope(_mapping_text(source, "scope_id"))), | ||
| (AccessAction.SCOPE_CONTRIBUTE, ResourceRef.scope(_nested_request_value(payload, "target_scope_id"))), |
There was a problem hiding this comment.
This lowers Topic Memory publication from scope.admin to scope.contribute in both Scopes. Combined with refresh, a user with scope.contribute in both Scopes can now change an existing shared Topic in the target, which RFC 1614 reserves for administrators: §7 keeps "Replace and replace tags" at scope.admin, and §13 says "Scope administration governs changes to existing shared knowledge".
I checked this on the merge result with one user who has scope.contributor in both Scopes:
- An administrator publishes source revision 1 to the target with key
K, then edits the target copy (target revision 2). - The contributor's
PUTon the target Topic returns 403. - After the source moves to revision 2, the contributor posts the publication with key
Kand source revision 2. It returns 201 withX-Publication-Outcome: replaced, and the target head becomes revision 3 with the source content, replacing the administrator's edit.
On master, the contributor gets 403 for both a first publication and the refresh. With SCOPE_ADMIN restored on these two lines, the only failure in the access, publication and Topic Memory suites is test_topic_memory_generic_writes_and_publication_use_scope_authority, whose grants this PR lowered to scope.contributor. So the refresh feature doesn't depend on the lower permission.
Please keep scope.admin in both Scopes for Topic Memory publication here, and revert the RFC, OpenAPI description, docs and access test to match. #2986 asks for scope.contribute, but RFC 1614 records the opposite decision with a rationale. Lowering it belongs in an RFC 1614 change that also decides which rule a refresh follows: a first publication resembles Create (scope.contribute), while a refresh resembles Replace (scope.admin).
Whichever rule stays, please document that a refresh replaces edits made to the copy in the target Scope. _find_request deliberately reads the latest publication "even if the target has since received a local edit", and neither topic-memory.md mentions it.
| _add_route(app, GET_ARTIFACT_REVISION, get_artifact_revision, response_model_exclude_unset=True) | ||
| _add_route(app, GET_ARTIFACT, get_artifact, response_model_exclude_unset=True) |
There was a problem hiding this comment.
Design note (non-blocking): response_model_exclude_unset=True affects more than published_from. _transport_actor builds AccessPrincipal(type=…, id=…) without description, so for a Profile rollback revision these two routes now return created_by as {"type": "user", "id": "…"}, while GET …/revisions still returns "description": null for the same revision. Master returns "description": null on all three. Passing description=None in _transport_actor makes the three routes match again; I checked that change against the same rollback.
|
This feature hasn't been approved yet, so I'll convert the PR into a draft. |
|
A follow-up to my review, with two points for when this moves forward.
|
Fixes #2986
Which issue or RFC does this PR close?
Closes #2986.
Rationale for this change
The publication key was bound to an exact source revision. A newer revision of the same Topic returned HTTP 409, and readers of a shared copy could not see which source revision it represented.
What changes are included in this PR?
Are there any user-facing changes?
Topic Memory publication requires
scope.contributein both Scopes. Successful publication responses reportcreated,skipped, orreplacedinX-Publication-Outcome. A published revision's details includepublished_fromwith the exact source Scope, Artifact, and revision. Other supported families retain the existing authorization and revision conflict rules.How was this change tested?
Tests:
uv run --locked pytest -v tests/e2e/test_topic_memory_generic_api.py::test_topic_publication_refresh_preserves_target_and_exact_provenance.Result: uv run --locked pytest -q tests/e2e/test_topic_memory_generic_api.py tests/builtin/test_publication.py tests/test_access_http.py (base): 61 passed
Result: uv run --locked pytest -v tests/e2e/test_topic_memory_generic_api.py::test_topic_publication_refresh_preserves_target_and_exact_provenance (base): 1 failed with HTTP 409 artifact_publication_conflict instead of HTTP 201
Result: uv run --locked pytest -v tests/e2e/test_topic_memory_generic_api.py::test_topic_publication_refresh_preserves_target_and_exact_provenance (patched): 1 passed
Result: uv run --locked pytest -q tests/e2e/test_topic_memory_generic_api.py tests/builtin/test_publication.py tests/test_access_http.py tests/builtin/persistence/test_topic_memory.py tests/e2e/test_artifact_tags.py tests/e2e/test_owner_recovery_http.py: 166 passed
Result: uv run --locked pytest -q tests/e2e/test_topic_memory_generic_api.py::test_index_failure_rolls_back_create_replace_and_publication tests/e2e/test_access_control_regressions.py::test_topic_memory_generic_writes_and_publication_use_scope_authority: 3 passed
Result: uv run --locked pytest -q tests/e2e/test_access_control_regressions.py tests/e2e/test_runtime_server.py tests/e2e/test_portable_archive.py -k 'topic_memory_generic_writes or publication or sdk_handoff_lifecycle': 11 passed, 2 skipped for unavailable non-SQLite backends, 261 deselected
Result: uv run --locked pytest -q tests/test_mcp.py tests/e2e/test_mcp_transport.py: 18 passed
Result: uv run --locked python .powercontext/osscout/publication_archive.py: restored both publication edges and retried an older source successfully
Result: uv run --locked ty check: passed
Result: uv run --locked ruff check --no-fix $(git diff --name-only -- '*.py'): passed
Regression coverage:
tests/e2e/test_topic_memory_generic_api.py.AI usage statement
OpenAI Codex (GPT-6) implemented the change, ran the checks, and authored this description.